<template>
  <div class="table-slot-wrapper">
    <span class="common-text" @click.stop="setTrack">{{ slotData.isTrack ? yes : no }}</span>
  </div>
</template>

<script>
  export default {
    name: 'IsTrackTableRender',
    props: {
      slotData: {
        type: Object,
        default: () => {}
      },
      dataType: {
        type: String,
        default: '0'
      }
    },
    data() {
      return {
        yes: $.i18n('common.yes'),
        no: $.i18n('common.no')
      };
    },
    methods: {
      setTrack() {
        var _that = this;
        if (this.dataType === '1') return;
        const { affairId, summaryId } = this.slotData;
        var dialog = $.dialog({
          targetWindow: getCtpTop(),
          id: 'trackDialog',
          url:
            _ctxPath +
            '/collaboration/collaboration.do?method=openTrackDetail&objectId=' +
            summaryId +
            '&affairId=' +
            affairId,
          width: 328,
          height: 100,
          title: $.i18n('common.track.setting'),
          buttons: [
            {
              id: 'trackSubmit',
              text: $.i18n('common.button.ok.label'),
              //确定
              handler: function handler() {
                var returnValue = dialog.getReturnValue();
                if(returnValue === undefined) return
                if (returnValue == '0') {
                  _that.slotData.isTrack = false;
                } else {
                  _that.slotData.isTrack = true;
                }
                dialog.close();
              }
            },
            {
              text: $.i18n('common.button.cancel.label'),
              //取消
              handler: function handler() {
                dialog.close();
              }
            }
          ]
        });
      }
    }
  };
</script>

<style lang="scss" scoped>
  .table-slot-wrapper {
    display: flex;
    align-items: center;
    width: 100%;

    .common-text {
      flex: 1;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      word-break: break-word;
      color: #2490f8;
      color: var(--theme-brand5, #2490f8);
      cursor: pointer;
    }
  }
</style>
